{% extends "ft/base.html" %}
{% load mytag %}
{% block title %}天天生鲜-用户中心页{% endblock %}
{% block css %}
    <link rel="stylesheet" href="/static/ft/css/usercenterinfo.css">
{% endblock %}
{% block content %}
    <div class="container">
        <!--2.搜索框开始-->
        <div class="search">
            <div class="row ">
                <!--左边图片和文字-->
                <div class="col-lg-5">
                    <img src="/static/ft/img/logo.png" alt="..." class="img-rounded">
                    <span>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;用户中心</span>
                </div>
                <!--右边表单-->
                <div class="col-lg-6 col-lg-offset-1 search_bar">
                    <form action="">
                        <div class="input-group">
                            <input type="text" class="form-control" placeholder="搜索商品">
                            <span class="input-group-btn">
                    <button class="btn btn-success" style="padding: 6px 50px" type="submit">搜索</button>
                </span>
                        </div>
                    </form>
                </div>
            </div>
        </div>


        <!--3.主体-->
        <div class="main">
            <ul class="nav nav-tabs">
                <li role="presentation"><a href="#">个人信息</a></li>
                <li role="presentation"><a href="#">全部订单</a></li>
                <li role="presentation" class="active"><a href="#">收货地址</a></li>
            </ul>
            <br/>
            <div class="info">
                <!--基本信息-->
                <div id="userinfo">
                    <div class="panel panel-default">
                        <div class="panel-heading col-lg-12">
                            <span class="col-lg-11">用户基本信息</span>
                            <span class="col-lg-1">
                            <a class="btn btn-default btn-xs" href="edit-user.html" role="button">&nbsp;&nbsp;修&nbsp;改&nbsp;&nbsp;</a>
                        </span>
                        </div>
                        <div class="panel-body">
                            <div>
                                用户名: {{ buyer.name }} <br/>
                                联系方式: {{ buyer.phone|default:"无" }} <br/>
                                联系地址: {{ buyer.address|default:"无" }}
                            </div>
                        </div>
                        <div class="panel-heading">最近浏览</div>
                        <div class="row">
                            <div class="col-md-3">
                                <a href="#" class="thumbnail">
                                    <img src="/static/ft/img/goods/goods006.jpg" alt="...">
                                </a>
                                <div style="text-align: center">
                                    <h4><a href="detail.html">进口西梅</a></h4>
                                    <span class="prize" style="color: red">￥16.80</span>
                                    <span class="unit">16.80/500g</span>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <a href="#" class="thumbnail">
                                    <img src="/static/ft/img/goods/goods001.jpg" alt="...">
                                </a>
                                <div style="text-align: center">
                                    <h4><a href="detail.html">大兴大棚草莓</a></h4>
                                    <span class="prize" style="color: red">￥16.80</span>
                                    <span class="unit">16.80/500g</span>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <a href="#" class="thumbnail">
                                    <img src="/static/ft/img/goods/goods004.jpg" alt="...">
                                </a>
                                <div style="text-align: center">
                                    <h4><a href="detail.html">吐鲁番梨光杏</a></h4>
                                    <span class="prize" style="color: red">￥16.80</span>
                                    <span class="unit">16.80/500g</span>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <a href="#" class="thumbnail">
                                    <img src="/static/ft/img/goods/goods005.jpg" alt="...">
                                </a>
                                <div style="text-align: center">
                                    <h4><a href="detail.html">黄肉桃</a></h4>
                                    <span class="prize" style="color: red">￥16.80</span>
                                    <span class="unit">16.80/500g</span>
                                </div>
                            </div>


                        </div>
                    </div>
                </div>
                <!--所有订单-->
                <div id="allorders">
                    <div class="panel panel-default ">
                        {% for order in order_list %}
                            <div class="panel-heading col-lg-12">状态：{% if order.status == 1 %}
                                待支付{% elif order.status == 2 %}待发货{% elif order.status == 3 %}
                                待收货{% elif order.status == 4 %}待评价{% else %}已完成{% endif %}
                                ---时间：{{ order.createtime|date:"Y-m-d H:i:s" }}---订单号：{{ order.id }}</div>
                            <div class="panel-body">
                                <table class="table table-bordered table-hover">
                                    <tbody>
                                    {% for orderdetail in order.orderdetail_set.all %}
                                        <tr align="center" valign="middle">
                                            <td>
                                                <img class="img-thumbnail"
                                                     src="/static/bg/img/{{ orderdetail.picture }}" width="60px" alt="">
                                            </td>
                                            <td style="vertical-align: middle;text-align: center;">{{ orderdetail.name }}</td>
                                            <td style="vertical-align: middle;text-align: center;">{{ orderdetail.price }}元/{{ orderdetail.unite }}</td>
                                            <td style="vertical-align: middle;text-align: center;">{{ orderdetail.count }}</td>
                                            <td style="vertical-align: middle;text-align: center;">{% widthratio orderdetail.price 1 orderdetail.count %}元</td>
                                            {% if forloop.first %}
                                                <td rowspan="{{ order.orderdetail_set.count }}" align="center"
                                                    style="vertical-align: middle;text-align: center;">
                                                    {% if order.status == 1 %}待支付{% elif order.status == 2 %}
                                                        待发货{% elif order.status == 3 %}待收货{% elif order.status == 4 %}
                                                        待评价{% else %}已完成{% endif %}
                                                </td>
                                                <td rowspan="{{ order.orderdetail_set.count }}"
                                                    style="vertical-align: middle;text-align: center;">
                                                    {% if order.status == 1 %}
                                                        <a href="/ft/order/pay/?order_id={{ order.id }}">去支付</a>
                                                    {% elif order.status == 2 %}
                                                        <a href="#">提醒发货</a>
                                                    {% elif order.status == 3 %}
                                                        <a href="#">确认收货</a>
                                                    {% elif order.status == 4 %}
                                                        <a href="#">去评价</a>
                                                    {% else %}
                                                        <a href="#">已完成，查看详情</a>
                                                    {% endif %}
                                                </td>
                                            {% endif %}
                                        </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                        {% endfor %}
                        <div align="center">
                            <nav aria-label="...">
                                <ul class="pagination">
                                    <li class="disabled"><a href="#" aria-label="Previous"><span
                                            aria-hidden="true">&laquo;</span></a></li>
                                    <li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
                                    <li><a href="#">2</a></li>
                                    <li><a href="#">3</a></li>
                                    <li><a href="#">4</a></li>
                                    <li><a href="#">5</a></li>
                                    <li>
                                        <a href="#" aria-label="Next">
                                            <span aria-hidden="true">&raquo;</span>
                                        </a>
                                    </li>
                                </ul>
                            </nav>
                        </div>
                    </div>
                </div>
                <!--收货地址-->
                <div id="address">
                    <div class="panel panel-default ">
                        <div class="panel-heading col-lg-12">当前地址:</div>
                        <div class="panel-body">
                            <div class="col-lg-8">
                                {% for receiver in receiver_list %}
                                    <div class="radio">
                                        <label>
                                            <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1"
                                                   checked>
                                            {{ receiver.address }} （{{ receiver.name }}
                                            收） {{ receiver.phone| filter_phone1 }}
                                        </label>
                                        <a href="/ft/user/center/address/edit/?id={{ receiver.id }}"
                                           class="btn btn-default">编辑</a>
                                    </div>
                                {% endfor %}
                            </div>
                        </div>
                        <div class="panel-heading">添加地址</div>
                        <div class="panel-body">
                            <div class="row col-lg-8" style="margin-top: 10px">
                                <form class="form-horizontal" method="post" action="/ft/user/center/address/add/">
                                    {% csrf_token %}
                                    <div class="form-group">
                                        <label for="shoujianren" class="col-sm-2 control-label">收件人</label>
                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" id="shoujianren" placeholder="收件人"
                                                   name="name">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="xiangxiaddress" class="col-sm-2 control-label">详细地址</label>
                                        <div class="col-sm-10">
                                    <textarea class="form-control" placeholder="详细地址" id="xiangxiaddress"
                                              rows="3" name="address"></textarea>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="youbian" class="col-sm-2 control-label">邮编</label>
                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" id="youbian" placeholder="邮政编码"
                                                   name="postcode">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="youbian" class="col-sm-2 control-label">手机</label>
                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" id="phone" placeholder="手机号"
                                                   name="phone">
                                        </div>
                                    </div>


                                    <div class="form-group">
                                        <button type="submit" class="btn btn-default col-lg-4 col-lg-offset-4">&nbsp;&nbsp;提&nbsp;交&nbsp;&nbsp;
                                        </button>
                                    </div>
                                </form>
                            </div>
                        </div>

                    </div>

                </div>
            </div>
        </div>

    </div>
{% endblock %}
{% block js %}
    <script>
        $(function () {
            // 选项卡切换
            $("ul li").on("click", function () {

                //获取索引值
                var index = $(this).index();
                $(".info>div").eq(index).show().siblings().hide();
                console.log($(this)[0]);
                $(this).addClass('active');
                $(this).siblings().removeClass('active');

            });
        });
    </script>
{% endblock %}